<template>
  <div
    v-if="secondLayerData.length"
    :id="`menuScroll${scrollFirstIndex}-${scrollSecondIndex}`"
    class="salary-container cardWrapper"
  >
    <div class="total-salary">
      <div class="salary-title">
        <img
          class="item-img"
          src="https://img3.job1001.com/data_center/images/position_item_icon.png"
          alt="404"
        />
        <span class="item-title">适用人群</span>
      </div>

      <div class="chartContainer">
        <div
          :class="['region-salary', 'bigger']"
          v-for="(item, index) in secondLayerData"
          :key="item.layerId"
          :id="`scroll${scrollSecondIndex}-${index}`"
        >
          <div v-if="item.layerId == 30" class="targetMajor" :key="index">
            <div class="controlLine">
              <span class="tinyTitle">
                <div class="titleFlag"></div>
                {{ item.title }}
              </span>
              <div class="line"></div>
            </div>
            <div class="otherNameContainer">
              <template v-for="(_item, _index) in item.data">
                <div class="otherName" :key="_index">
                  {{
                    _item.layerValue
                      ? _item.description + '  ' + _item.layerValue
                      : _item.tagName
                  }}{{ `（${getCateTypeName(_item.cateType)}）` }}
                </div>
              </template>
            </div>
          </div>
          <!-- radarChartVue和工作风险那边的组件不一样哦 -->
          <radarChartBigger
            :layerData.sync="item"
            :layerId="item.layerId"
            v-else-if="item.layerId == 20"
            :isAdmin="isAdmin"
            :isSuperToken="isSuperToken"
            :thirdScrollIndex="index"
          />
          <radarChartVue
            :layerData.sync="item"
            :layerId="item.layerId"
            v-else
            :isAdmin="isAdmin"
            :isSuperToken="isSuperToken"
            :chartRadius="'60%'"
            :thirdScrollIndex="index"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'targetGroup',
  components: {
    radarChartVue: () => import('../../components/radarChart.vue'),
    radarChartBigger: () => import('../../components/radarChartBigger.vue')
  },
  props: {
    secondLayerData: {
      type: Array,
      default: () => []
    },
    scrollFirstIndex: {
      type: [String, Number],
      default: 0
    },
    scrollSecondIndex: {
      type: [String, Number],
      default: 0
    },
    topId: {
      type: String,
      required: true
    },
    isSuperToken: {
      type: Boolean,
      default: false
    },
    isAdmin: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      cateTypeOptions: [
        { name: '高职专科', value: 10 },
        { name: '高职本科', value: 20 },
        { name: '普通本科', value: 30 },
        { name: '中专', value: 40 },
        { name: '硕士', value: 50 }
      ]
    };
  },
  watch: {
    secondLayerData: {
      handler(newValue, oldValue) {
        // //console.log("enterpriseRecruitmentNeeds secondLayerData", newValue);
      },
      immediate: true
    }
  },
  methods: {
    getCateTypeName(val) {
      if (!val) return '学历未知';
      return this.cateTypeOptions.find((item) => item.value === val).name;
    }
  }
};
</script>

<style scoped lang="scss">
.cardWrapper {
  margin-bottom: 14px;
}
.list {
  /* height: 630px;
    overflow-y: auto; */
}
.salary-container {
  position: relative;
  min-width: 800px;
  padding-top: 0px;
  padding-right: 0px;

  overflow: scroll;
  &::-webkit-scrollbar {
    width: 4px;
    background-color: #fff;
    border-radius: 4px;

    height: 4px;
  }
  &::-webkit-scrollbar-thumb {
    background-color: #d8d8d8;
    border-radius: 4px;
  }
}
.total-salary {
  // background: linear-gradient(0, #eaf5ff 0%, #ffffff 100%);
  background-size: 100% 219px;
  background-repeat: no-repeat;
  background-image: url('https://img3.job1001.com/data_center/images/salary_bg.png?v=1');
  // background: #ffffff;
  border-radius: 10px;
  border: 1px solid #cbdcfe;
  padding: 20px 20px 11px;
}
.cate-salary {
  // background: linear-gradient(0, #eaf5ff 0%, #ffffff 100%);
  background-size: 100% 293px;
  background-repeat: no-repeat;
  background-image: url('https://img3.job1001.com/data_center/images/salary_bg.png?v=1');
  // background: #ffffff;
  border-radius: 10px;
  border: 1px solid #cbdcfe;
  margin-top: 14px;
  padding: 20px;
}
.salary-title {
  display: flex;
  align-items: center;
  .item-img {
    width: 39px;
    height: 40px;
    align-self: center;
  }
  .item-title {
    margin-left: 10px;
    color: #000;
    font-size: 22px;
    font-weight: bold;
    font-family: PingFang SC;
  }
}
.chartContainer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 20px;
  .region-salary {
    min-width: 48%;
    &.bigger {
      width: 100%;
      ::v-deep.secondItem {
        width: 100%;
        justify-content: space-between;
      }
    }
  }
  .targetMajor {
    .controlLine {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      margin-bottom: 15px;
      .tinyTitle {
        display: flex;
        align-items: center;
        font-weight: bold;
        font-size: 18px;
        .titleFlag {
          width: 5px;
          height: 15px;
          border-radius: 3px;
          background: #4880ff;
          margin-right: 12px;
        }
      }
      .line {
        flex: 1;
        margin-left: 14px;
        border-bottom: 1px solid #efefef;
      }
    }
    .otherNameContainer {
      display: flex;
      flex-wrap: wrap;
      align-content: flex-start;
      flex: 1;
      &.inEdit {
        max-width: 50%;
      }
      .otherName {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 38px;
        border-radius: 4px;
        border: 1px solid #b2bad4;
        padding: 7px 18px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
        line-height: 24px;
        margin-right: 18px;
        margin-bottom: 24px;
      }
    }
  }
}

.isShitBrowser {
  background-position: 0px 0px;
}
</style>
